const axios = require('axios')
let _baseUrl = '/gateway/business/api'

// 获取公开项目列表
export function getPublicProjectList (query) {
  const url = _baseUrl + '/project/getPublicProjectList' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 公开项目统计
export function getPublicProjectCollectInfo () {
  const url = _baseUrl + '/project/getPublicProjectCollectInfo'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取公开项目
export function getPublicProject (query) {
  const url = _baseUrl + '/project/openProject' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取公开项目明细
export function getPublicProjectDetail (query) {
  const url = _baseUrl + '/project/getPublicProjectDetail' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

//  获取公开项目关联最多的5个标签
export function getTopFiveRelationCategory (data) {
  const url = _baseUrl + '/category/getTopFiveRelationCategory'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

//  获取分类树信息
export function getCategoryTreeByType () {
  const url = _baseUrl + '/category/getCategoryTreeByType?type=1'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 批量保存分类 公开项目
export function saveCategoryRelationList (data) {
  const url = _baseUrl + '/category/saveCategoryRelationList'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

//  获取项目历史公开信息和成功任务接口
export function publicProjectInfo (data) {
  const url = _baseUrl + '/publicProjectInfo'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

//  获取运行任务列表
export function getProjectPublicJob (query) {
  const url = _baseUrl + '/project/getProjectPublicJob' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

//  获取公开用户任务详情
export function getUserPublicTaskDetail (query) {
  // const url = _baseUrl + '/getProjectPublicJob'
  const url = _baseUrl + '/project/getUserPublicTaskDetail' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取任务语言框架
export function getJobEnvironment (query) {
  const url = _baseUrl + '/getJobEnvironment' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询任务详情
export function getJobInfo (query) {
  const url = _baseUrl + '/getJobInfo' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取任务参数
export function getJobParams (query) {
  const url = _baseUrl + '/getJobParams' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}
